import { ElMessage, ElMessageBox } from "element-plus";

export const useConfirm = (row, delFunctionApi, onTableData) => {
  ElMessageBox.confirm("确定删除该条数据吗?", "QFADMIN温馨提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(async () => {
      const { state, msg } = await delFunctionApi(row);
      if (state === 200) {
        ElMessage.success(msg);
        onTableData();
      } else {
        ElMessage.error(msg);
      }
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "用户取消",
      });
    });
};
